package notify

import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingQueue
import kotlin.concurrent.thread

private val chickens: BlockingQueue<Chicken> = LinkedBlockingQueue(10)

fun main() {
    thread { product() }
    thread { custom() }
}

fun product() {
    for (i in 1..100) {
        println("生产了$i 只鸡")
        chickens.put(Chicken(i))
    }
}

fun custom() {
    for (i in 1..100) {
        println("吃掉了第${chickens.take().id} 只鸡")
    }
}

data class Chicken(
    val id: Int
)


